package com.chf.carsystem.users.systemmanagement;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.chf.carsystem.common.util.DateUtil;
import com.chf.carsystem.users.pojo.MyEnum;
import com.chf.carsystem.users.pojo.Role;
import com.chf.carsystem.users.service.IUserService;
/**
 * 系统管理controller
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/head/")
public class SystemManagementController {

	//工具类
	private DateUtil dateUtil;
	private IUserService userService;
	
	//打开角色管理页面 
	@RequestMapping("/roleMonitoring")
	public String roleMonitoring()
	{
		return "/head/roleMonitoring";
	}
	//模糊查询所有角色的提交方法
	@RequestMapping("/selectRoleSubmit")
	public String selectRoleSubmit(String id,String name,String status,
			String createTime,String UpdateTime,String pubTime)
	{
		Map<String,Object> findCoundListMap = new HashMap<String,Object>();
		
		//得到参数 放到map中
		if(id != null && id != "")
		{
			findCoundListMap.put("id",id);
		}	
		if(name != null && name != "")
		{
			findCoundListMap.put("name",name);
		}	
		if(status != null && status != "")
		{
			//引用枚举
			MyEnum[] myEnums = MyEnum.values();
			for (int i = 0; i < myEnums.length; i++) {
				MyEnum myEnum = myEnums[i];
				if(Byte.valueOf(status) == myEnum.getStatus() && myEnum.toString().startsWith("ROLESTATUS_"));
				{
					//放入map中
					findCoundListMap.put("status",status);
				}
			}
		}
		//时间属性的操作  引用时间的工具类
		if(createTime != null && createTime != "")
		{
			//转换为时间格式
			Date cTime = this.dateUtil.getDate(createTime);
			findCoundListMap.put("createTime", createTime);
		}
		if(UpdateTime != null && UpdateTime != "")
		{
			//转换为时间格式
			Date uTime = this.dateUtil.getDate(UpdateTime);
			findCoundListMap.put("UpdateTime", UpdateTime);
		}
		if(pubTime != null && pubTime != "")
		{
			//转换为时间格式
			Date pTime = this.dateUtil.getDate(pubTime);
			findCoundListMap.put("pubTime", pubTime);
		}
		
		//调用service层的方法 模糊查询role集合
		List<Role> RoleList = this.userService.finCountListRolesService(findCoundListMap);
		
		
		return "";
	}
	
	
	
	
	
	//日志管理
	@RequestMapping("/logMonitoring")
	public String logMonitoring()
	{
		return "/head/logMonitoring";
	}
	
	//日志管理
	@RequestMapping("/loginMonitoring")
	public String loginMonitoring()
	{
		return "/head/loginMonitoring";
	}
	
}
